﻿// <copyright file="MySpaceContainer.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2008-09-23</date>
// <summary>The Silverlight Application</summary>

namespace MyOpenSpace
{
    using System;
    using System.Diagnostics.CodeAnalysis;
    using System.Windows.Browser;

    /// <summary>
    /// The MySpace container class, extends opensocial.Container
    /// </summary>
    public class MySpaceContainer
    {
        #region Member Data
        /// <summary>
        /// Script container
        /// </summary>
        private ScriptObject container;
        #endregion

        #region Constructors
        /// <summary>
        /// Initializes a new instance of the MySpaceContainer class
        /// </summary>
        internal MySpaceContainer()
        {
            this.container = HtmlPage.Window.Eval("opensocial.Container.get()") as ScriptObject;

            // Only call this in this from an iframe
            ////var ownerId = HtmlPage.Document.QueryString["ownerId"];

            ////this.container.Invoke("registerParam", "ownerid", ownerId);
        }
        #endregion

        #region Methods
        /// <summary>
        /// Make a request
        /// </summary>
        /// <param name="url">the URL where the content is located</param>
        /// <param name="callback">the function to call with the data returned from the URL</param>
        /// <param name="additional">parameters to pass to the request</param>
        /// <remarks>Ignore SA1300</remarks>
        [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", 
            MessageId = "make", Justification = "Mirroring OpenSocial API.")]
        public void makeRequest(
            Uri url, 
            EventHandler<opensocial.RequestEventArgs> callback, 
            object additional)
        {
            this.container.Invoke("makeRequest", url, callback, additional);
        }

        /// <summary>
        /// Returns the container environment object
        /// </summary>
        /// <returns>the OpenSocial environment</returns>
        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", 
            Justification = "Mirroring OpenSocial API."),  
         SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", 
             MessageId = "get", Justification = "Mirroring OpenSocial API.")]
        public opensocial.Environment getEnvironment()
        {
            var environment = this.container.Invoke("getEnvironment") as ScriptObject;

            return new opensocial.Environment(environment);
        }

        /// <summary>
        /// Returns a new MyOpenSpace.Person instance
        /// </summary>
        /// <param name="opt_params">optional parameters</param>
        /// <param name="opt_isViewer">true if the new person is the viewer</param>
        /// <param name="opt_isOwner">true if the new person is the owner</param>
        /// <returns>a new person</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "is", Justification = "Mirroring OpenSocial API.")]
        public opensocial.Person newPerson(object opt_params, bool opt_isViewer, bool opt_isOwner)
        {
            var person = this.container.Invoke("newPerson", opt_params, opt_isViewer, opt_isOwner) as ScriptObject;

            return new opensocial.Person(person);
        }

        /// <summary>
        /// Returns a new MyOpenSpace.Album instance
        /// </summary>
        /// <param name="opt_params">optional paramters</param>
        /// <returns>a new album</returns>
        /// <remarks>Ignore SA1300</remarks>
        [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", 
            Justification = "Mirroring OpenSocial API."),
         SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", 
             MessageId = "params", Justification = "Mirroring OpenSocial API."), 
         SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly",
             MessageId = "params", Justification = "Mirroring OpenSocial API."), 
        SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", 
            MessageId = "new", Justification = "Mirroring OpenSocial API.")]
        public MyOpenSpace.Album newAlbum(object opt_params)
        {
            var album = this.container.Invoke("newAlbum", opt_params) as ScriptObject;

            return new MyOpenSpace.Album(album);
        }

        /// <summary>
        /// Returns a new MyOpenSpace.Video instance
        /// </summary>
        /// <param name="opt_params">optional parameters</param>
        /// <returns>a new video</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API.")]
        public MyOpenSpace.Video newVideo(object opt_params)
        {
            var video = this.container.Invoke("newVideo", opt_params) as ScriptObject;

            return new MyOpenSpace.Video(video);
        }

        /// <summary>
        /// Returns a new MyOpenSpace.Photo instance
        /// </summary>
        /// <param name="opt_params">optional parameters</param>
        /// <returns>a new Photo object</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API.")]
        public MyOpenSpace.Photo newPhoto(object opt_params)
        {
            var photo = this.container.Invoke("newPhoto", opt_params) as ScriptObject;

            return new MyOpenSpace.Photo(photo);
        }

        /// <summary>
        /// Returns a new opensocial.DataRequest instance, which is overridden locally
        /// </summary>
        /// <returns>a new data request</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring opensocial API.")]
        public opensocial.DataRequest newDataRequest()
        {
            var dataRequest = this.container.Invoke("newDataRequest") as ScriptObject;

            return new opensocial.DataRequest(dataRequest);
        }

        /// <summary>
        /// Returns a new opensocial.ResponseItem instance
        /// </summary>
        /// <param name="originalDataRequest">original data request</param>
        /// <param name="data">data for the response item</param>
        /// <param name="opt_errorCode">error code</param>
        /// <param name="opt_errorMessage">error message</param>
        /// <returns>a new response item</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "error", Justification = "Mirroring OpenSocial API.")]
        public opensocial.ResponseItem newResponseItem(opensocial.DataRequest originalDataRequest, object data, string opt_errorCode, string opt_errorMessage)
        {
            var responseItem = this.container.Invoke("newResponseItem", originalDataRequest.ScriptObject, data, opt_errorCode, opt_errorMessage) as ScriptObject;

            return new opensocial.ResponseItem(responseItem);
        }

        /// <summary>
        /// Creates an object to be used when sending to the server.
        /// </summary>
        /// <param name="idSpec">the ID of the person</param>
        /// <param name="opt_params">optional parameters</param>
        /// <returns>a new fetch person request</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API.")]
        public ScriptObject newFetchPersonRequest(opensocial.IdSpec idSpec, object opt_params)
        {
            ScriptObject request = this.container.Invoke("newFetchPersonRequest", idSpec.ScriptObject, opt_params) as ScriptObject;

            return request;
        }

        /// <summary>
        /// Creates an object to be used when sending to the server.
        /// </summary>
        /// <param name="idSpec">the ID of the person</param>
        /// <param name="opt_params">optional parameters</param>
        /// <returns>a new fetch person request</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API.")]
        public ScriptObject newFetchPersonRequest(string idSpec, object opt_params)
        {
            ScriptObject request = this.container.Invoke("newFetchPersonRequest", idSpec, opt_params) as ScriptObject;

            return request;
        }

        /// <summary>
        /// Creates an object to be used when sending to the server.
        /// </summary>
        /// <param name="id">the person id</param>
        /// <param name="photo_id">the photo id</param>
        /// <param name="opt_params">optional parameters</param>
        /// <returns>a new fetch photo request</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "id", Justification = "Mirroring OpenSocial API.")]
        public ScriptObject newFetchPhotoRequest(string id, int photo_id, object opt_params)
        {
            ScriptObject request = this.container.Invoke("newFetchPhotoRequest", id, photo_id, opt_params) as ScriptObject;

            return request;
        }

        /// <summary>
        /// Creates an object to be used when sending to the server.
        /// </summary>
        /// <param name="id">the person ID</param>
        /// <param name="opt_params">optional parameters</param>
        /// <returns>a new fetch photos request</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API.")]
        public ScriptObject newFetchPhotosRequest(string id, object opt_params)
        {
            ScriptObject request = this.container.Invoke("newFetchPhotosRequest", id, opt_params) as ScriptObject;

            return request;
        }

        /// <summary>
        /// Creates an object to be used when sending to the server.
        /// </summary>
        /// <param name="id">the User ID</param>
        /// <param name="album_id">the album ID</param>
        /// <param name="opt_params">optional parameters</param>
        /// <returns>a new fetch album request</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "id", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring opensocial API.")]
        public ScriptObject newFetchAlbumRequest(string id, int album_id, object opt_params)
        {
            ScriptObject request = this.container.Invoke("newFetchAlbumRequest", id, album_id, opt_params) as ScriptObject;

            return request;
        }

        /// <summary>
        /// Creates an object to be used when sending to the server.
        /// </summary>
        /// <param name="id">id of a user</param>
        /// <param name="opt_params">optional parameters</param>
        /// <returns>a new fetch albums request</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", 
            MessageId = "params", Justification = "Mirroring OpenSocial API."), 
         SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", 
             MessageId = "new", Justification = "Mirroring opensocial API.")]
        public ScriptObject newFetchAlbumsRequest(string id, object opt_params)
        {
            ScriptObject request = this.container.Invoke("newFetchAlbumsRequest", id, opt_params) as ScriptObject;

            return request;
        }

        /// <summary>
        /// Creates an object to be used when sending to the server.
        /// </summary>
        /// <param name="id">the user ID</param>
        /// <param name="video_id">the video ID</param>
        /// <param name="opt_params">optional parameters</param>
        /// <returns>a new fetch video request</returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "id", Justification = "Mirroring OpenSocial API.")]
        public ScriptObject newFetchVideoRequest(string id, int video_id, object opt_params)
        {
            ScriptObject request = this.container.Invoke("newFetchVideoRequest", id, video_id, opt_params) as ScriptObject;

            return request;
        }

        /// <summary>
        /// Creates an object to be used when sending to the server
        /// </summary>
        /// <param name="id">the user ID</param>
        /// <param name="opt_params">optional paramters</param>
        /// <returns>a new Fetch videos request</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API.")]
        public ScriptObject newFetchVideosRequest(string id, object opt_params)
        {
            ScriptObject request = this.container.Invoke("newFetchVideosRequest", id, opt_params) as ScriptObject;

            return request;
        }

        /// <summary>
        /// Creates an item to request friends from the server. When processed, returns an opensocial.Collection&lt;MyOpenSpace.Person&gt; object.
        /// </summary>
        /// <param name="idSpec">ID specification</param>
        /// <param name="opt_params">optional parameters</param>
        /// <returns>a new fetch people request</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API.")]
        public ScriptObject newFetchPeopleRequest(opensocial.IdSpec idSpec, object opt_params)
        {
            ScriptObject request = this.container.Invoke("newFetchPeopleRequest", idSpec.ScriptObject, opt_params) as ScriptObject;

            return request;
        }

        /// <summary>
        /// Creates an item to request friends from the server. When processed, returns an opensocial.Collection&lt;MyOpenSpace.Person&gt; object.
        /// </summary>
        /// <param name="idSpec">ID specification</param>
        /// <param name="opt_params">optional parameters</param>
        /// <returns>a new fetch people request</returns>
        /// <remarks>Ignore SA1300</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "params", Justification = "Mirroring OpenSocial API."), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "new", Justification = "Mirroring OpenSocial API.")]
        public ScriptObject newFetchPeopleRequest(string idSpec, object opt_params)
        {
            ScriptObject request = this.container.Invoke("newFetchPeopleRequest", idSpec, opt_params) as ScriptObject;

            return request;
        }

        #endregion
    }
}
